//
//  HotSingerCollectionViewCell.m
//  DolphinMusic
//
//  Created by dllo on 15/3/24.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "HotSingerCollectionViewCell.h"

@implementation HotSingerCollectionViewCell

- (void)dealloc
{
    [_singer release];
    [_singerImageView release];
    [_nameLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.singerImageView = [[UIImageView alloc] init];
        self.singerImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:self.singerImageView];
        [_singerImageView release];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
        
    }
    return self;
}


- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
}

- (void)setSinger:(Singer *)singer
{
    if (_singer != singer) {
        [_singer release];
        _singer = [singer retain];
    }
    self.singerImageView.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.width);
    [self.singerImageView setImageWithURL:[NSURL URLWithString:[singer.avatar_middle stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
    
    self.nameLabel.frame = CGRectMake(0, self.contentView.frame.size.width, self.contentView.frame.size.width, self.contentView.frame.size.height - self.contentView.frame.size.width);
    self.nameLabel.text = singer.name;
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    self.nameLabel.font = [UIFont systemFontOfSize:14];
    
}


@end
